/*
	Kapselt das Auslesen und normieren der jeweiligen Controllerinputs
	und bietet ein Interface fuer die Middleware
*/

#include <irrlicht.h>

#ifndef CONTROLLER_H
#define CONTROLLER_H

typedef struct OptParams{
	void *info;
} OptParams;

typedef struct DeviceInfo{	//gibt jeweils an, ob der Input des Devices fuer eine Aktion
	bool rotXbin;			//binaer ist oder nicht
	bool rotYbin;
	bool rotZbin;
	bool cursorXbin;
	bool cursorYbin;
	bool objectYBin;
	bool selectObjectBin;
	bool dropObjectBin;
	bool endApplicationBin;
} DeviceInfo;

typedef struct ActionReturn{
	bool actionOccured;
	bool binValuePositive;
	float actionValue;
} ActionReturn;

class Controller{

public:
	virtual void initController(DeviceInfo *c) const = 0;
	virtual void updateController() const = 0;
	virtual void drop() const = 0;

	virtual void getRotateX(ActionReturn *a) const = 0;
	virtual void getRotateY(ActionReturn *a) const = 0;
	virtual void getRotateZ(ActionReturn *a) const = 0;
	virtual void getRotateGame(ActionReturn *a) const = 0;
	virtual void getMoveCursorX(ActionReturn *a) const = 0;
	virtual void getMoveCursorY(ActionReturn *a) const = 0;
	virtual void getMoveObjectY(ActionReturn *a) const = 0;
	virtual void getSelectObject(ActionReturn *a) const = 0;
	virtual void getDropObject(ActionReturn *a) const = 0;
	virtual void getEndApplication(ActionReturn *a) const = 0;
};

class WiiController : public Controller{

public:
	WiiController(DeviceInfo *c);
	WiiController(DeviceInfo *c, OptParams o, int length);
	~WiiController(void);

	virtual void initController(DeviceInfo *c) const;
	virtual void updateController() const;
	virtual void drop() const;

	virtual void getRotateX(ActionReturn *a) const; 
	virtual void getRotateY(ActionReturn *a) const;
	virtual void getRotateZ(ActionReturn *a) const;
	virtual void getRotateGame(ActionReturn *a) const; 
	virtual void getMoveCursorX(ActionReturn *a) const; 
	virtual void getMoveCursorY(ActionReturn *a) const; 
	virtual void getMoveObjectY(ActionReturn *a) const;
	virtual void getSelectObject(ActionReturn *a) const; 
	virtual void getDropObject(ActionReturn *a) const; 
	virtual void getEndApplication(ActionReturn *a) const;

};

class MouseController : public Controller{

public:
	MouseController(DeviceInfo *c);
	MouseController(DeviceInfo *c, OptParams o, int length);
	~MouseController(void);

	virtual void initController(DeviceInfo *c) const;
	virtual void updateController() const;
	virtual void drop() const;

	virtual void getRotateX(ActionReturn *a) const; 
	virtual void getRotateY(ActionReturn *a) const;
	virtual void getRotateZ(ActionReturn *a) const;
	virtual void getRotateGame(ActionReturn *a) const; 
	virtual void getMoveCursorX(ActionReturn *a) const; 
	virtual void getMoveCursorY(ActionReturn *a) const;
	virtual void getMoveObjectY(ActionReturn *a) const;
	virtual void getSelectObject(ActionReturn *a) const; 
	virtual void getDropObject(ActionReturn *a) const; 
	virtual void getEndApplication(ActionReturn *a) const;

};

#endif